<template>
  <div ref="pay58">
    <div class="temp_plate print-wrap-58 print-wrap-normal"
      style="width: 58mm;font-size: 12px;
        padding: 10px;
        border: 1px solid #a5a5a5;
        box-shadow: 2px 2px 2px #d3d3d3;text-align: left;"
    >
      <h2 style="text-align:center; ">
        {{seller ? seller.name : "酒店"}}支付单
      </h2>

      <p class="panelone panelone1_2 panelone2">
        <span>单号:</span>
        <span class="inputspan">{{ changInfo ? changInfo.terminalTrace : 'S20200101001' }}</span>
      </p>

      <p class="panelone panelone1_2 panelone2">
        <span>支付方式:</span>
        <span>扫码支付</span>
        <span>金额:</span>
        <span v-if="changInfo">
          <span v-if="changInfo.totalFee">{{ changInfo.totalFee / 100}}</span>
          <span v-else>198</span>
        </span>
        <span v-else>198</span>
      </p>


      <div v-html="printconfig.note" style="margin-top: 10px;" class="mf15mmwithbigsize"></div>

      <p class="panelone" style="margin-top: 10px;">
        <span>付款时间:</span>
        <span v-if="changInfo">
          <span v-if="changInfo.terminalTime">{{ changInfo.terminalTime }}</span>
          <span v-else>2019年8月6日 13:13</span>
        </span>
        <span v-else>2019年8月6日 13:13</span>
      </p>
      <p class="panelone">
        <span>打印时间:</span>
        <span>{{ nowDate + ' ' + nowTime + ' ' }}</span>
      </p>
      <p class="panelone">
        <span>联系电话:</span>
        <span>{{ seller ? seller.tel : '021-000000' }}</span>
      </p>

      <p class="panelone">
        <span>酒店地址:</span>
        <span>{{ seller ? seller.address : '上海维也纳酒店' }}</span>
      </p>

      <div style="margin: 8px 0px;">
        操作员：{{user?user.username:'System'}}
      </div>

      <div style="font-weight:bold;font-size:16px;margin-top:18px; ">
        <span class="signtext" style="width:40%;">住客签字:</span>
        <span style="width:55%;" class="inputspan"></span>
      </div>
    </div>
  </div>
</template>

<script>
import moment from 'moment';
export default {
  data() {
    return {
      nowDate: '', // 当前日期
      nowTime: '', // 当前时间
      nowWeek: '', // 当前星期
      today: moment().format('YYYY-MM-DD'),
      seller: {},
      user: {},
      printconfig:{},
      changInfo:{},
    };
  },
  methods: {
    setData(changInfo){
      this.changInfo = changInfo
    },
    currentTime() {
      setInterval(this.getDate, 500);
    },
    getUser() {
      this.$http({
        url: this.$http.adornUrl(`/hotel/thotelprinttemplate/printInfo`),
        method: 'get'
      }).then(({ data }) => {
        if (data.code === 0) {
          this.user = data.user;
          this.seller = data.seller;
        }
      });
    },
    getDate: function() {
      var _this = this;
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1;
      let dd = new Date().getDate();
      let week = new Date().getDay();
      let hh = new Date().getHours();
      let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes();
      if (week == 1) {
        this.nowWeek = '星期一';
      } else if (week == 2) {
        this.nowWeek = '星期二';
      } else if (week == 3) {
        this.nowWeek = '星期三';
      } else if (week == 4) {
        this.nowWeek = '星期四';
      } else if (week == 5) {
        this.nowWeek = '星期五';
      } else if (week == 6) {
        this.nowWeek = '星期六';
      } else {
        this.nowWeek = '星期日';
      }
      _this.nowTime = hh + ':' + mf;
      _this.nowDate = yy + '-' + mm + '-' + dd;
    }
  },
  mounted() {
    this.currentTime();
    this.getUser();
    this.$http({
      url: this.$http.adornUrl(`/hotel/thotelprinttemplate/info/8`),
      method: 'get'
    }).then(({
      data
    }) => {
      if (data && data.code === 0) {
        this.printconfig = data.tHotelPrintTemplate;
      } else {
        this.$message.error(data.msg);
      }
    });
  }
};
</script>

<style lang="scss">
  .name{

  }
</style>
